<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex flex-wrap align-center justify-center benben-position-layout flex passwordLogin_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view style="font-size: 36rpx;font-weight: 500;">登录</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---logoflex布局开始-->
			<view
				class="flex flex-direction flex-wrap align-center justify-center benben-flex-layout passwordLogin_flex_1">
				<image class='passwordLogin_fd1_0' mode="aspectFit" :src='STATIC_URL+"logo.png"'></image>
				<text class='passwordLogin_fd1_1'>勇知行小程序</text>
			</view>

			<!---logoflex布局结束-->
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout passwordLogin_flex_2">
				<text class='passwordLogin_fd2_0'>申请获取以下权限</text>
				<text class='passwordLogin_fd2_1'>获取你的手机号信息</text>
				<button class='flex flex-wrap align-center justify-center passwordLogin_fd2_2'
					open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
					<!-- <image class='passwordLogin_fd2_2_c0' mode="aspectFit" :src='STATIC_URL+"479.png"'></image> -->
					<text class='passwordLogin_fd2_2_c1'>绑定手机号</text>
				</button>
			</view>

			<!---flex布局flex布局结束-->
			<!-- <view class="flex flex-wrap align-center justify-center benben-position-layout flex passwordLogin_flex_3">
				<benben-flex-switch-new class-name='flex flex passwordLogin_fd3_0' v-model="is_tick" :disabled='false'>
					<template v-slot:checked>

						<view class='flex flex position-relative align-center'>
							<image class='passwordLogin_checkfd3_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"639.png"'>
							</image>
						</view>

					</template>
					<template v-slot:unchecked>

						<view class='flex flex position-relative justify-end align-center'>
							<image class='passwordLogin_noCheckfd3_0_c1_c0' mode="aspectFit"
								:src='STATIC_URL+"213.png"'></image>
						</view>

					</template>
				</benben-flex-switch-new>
				<text class='passwordLogin_fd3_1'>{{$t('已阅读并同意')}}</text>
				<text class='passwordLogin_fd3_2'>{{$t('《用户注册协议》')}}</text>
				<text class='passwordLogin_fd3_1'>{{$t('与')}}</text>
				<text class='passwordLogin_fd3_2'>{{$t('《隐私协议》')}}</text>

			</view> -->
			<view :style="{height: '88rpx'}"></view>


		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"is_tick": false,
				"code": "",
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			uni.login({
				success: res => {
					this.code = res.code;
				}
			});
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// 获取手机号
			getPhoneNumber(e) {
				console.log(e);
				if (e.detail.errMsg.indexOf("user deny") !== -1) {
					uni.navigateBack();
				} else {
					this.bindMoblile(e.detail.encryptedData, e.detail.iv);
				}
			},
			bindMoblile(encryptedData, iv) {
				uni.showLoading({
					title: '绑定中...'
				})
				uni.getUserInfo({
					provider: 'weixin',
					success: infoRes => {
						if (this.code) {
							this.$api.post(global.API_VERSION + '65438496eb761', {
									invite_code: uni.getStorageSync('invite_code') ? uni.getStorageSync('invite_code') : "",
									encryptedData: encryptedData,
									iv: iv,
									code: this.code,
								}).then(res => {
									let result = res.data;
									uni.hideLoading();
									if (result.code == 1) {
										this.$message.info(result.msg);
										// uni.removeStorageSync('Wxinfo_tmp');
										this.$store.commit('updateUserInfo', result.data.userinfo);
										this.$store.commit('saveToken', result.data.userinfo.user_token);

										this.resetGetUserInfo().finally(_ => {
											setTimeout(() => {
												// uni.navigateBack({
												// 	delta: 2
												// })
												uni.switchTab({
													url: '/pages/tabBar/homePage/homePage'
												})
											}, 800)
										})

									} else {
										this.$message.info(result.msg);
									}
								})
								.catch(err => {
									uni.hideLoading();
									console.log('ERROR', err);
								})
						} else {
							uni.hideLoading();
							this.$message.info('授权失败');
						}
					},
					fail: err => {
						uni.hideLoading();
						console.log('ERROR', err)
					}
				});
			},
		}
	}
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #fff;
		background-size: 100% auto;
		background: url(https://yongzhixing.niurenjianzhan.com/uploads/mini/1.png) no-repeat;
	}

	.passwordLogin_flex_0 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.passwordLogin_flex_1 {
		padding: 100rpx 0rpx 190rpx 0rpx;
	}

	.passwordLogin_fd1_1 {
		color: #333333;
		font-size: 36rpx;
		font-weight: 700;
		line-height: 50rpx;
	}

	.passwordLogin_fd1_0 {
		width: 184rpx;
		height: 184rpx;
		margin: 0rpx 0rpx 36rpx 0rpx;
		border-radius: 16rpx;
	}

	.passwordLogin_flex_2 {
		padding: 0rpx 54rpx 0rpx 54rpx;
	}

	.passwordLogin_fd2_2_c1 {
		color: #FFFFFF;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 45rpx;
	}

	.passwordLogin_fd2_2_c0 {
		width: 38rpx;
		height: 32rpx;
		margin: 0rpx 14rpx 0rpx 0rpx;
	}

	.passwordLogin_fd2_2 {
		background: #F35D2A;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		width: 640rpx;
		height: 88rpx;
	}

	.passwordLogin_fd2_1 {
		color: #808080;
		font-size: 24rpx;
		font-weight: 400;
		line-height: 33rpx;
		margin: 0rpx 0rpx 40rpx 0rpx;
	}

	.passwordLogin_fd2_0 {
		color: #1A1A1A;
		font-size: 32rpx;
		font-weight: 700;
		margin: 0rpx 0rpx 16rpx 0rpx;
	}

	.passwordLogin_flex_3 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		background-size: 100% auto !important;
	}

	.passwordLogin_fd3_2 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(173, 56, 35, 1);
	}

	.passwordLogin_fd3_1 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
	}

	.passwordLogin_noCheckfd3_0_c1_c0 {
		border-radius: 12rpx 12rpx 12rpx 12rpx;
		width: 32rpx;
		height: 32rpx;
		margin: 6rpx 0rpx 0rpx 0rpx;
	}

	.passwordLogin_checkfd3_0_c0_c0 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 12rpx 12rpx 12rpx 12rpx;
		margin: 6rpx 0rpx 0rpx 0rpx;
	}

	::v-deep .passwordLogin_fd3_0 {
		margin: 0rpx 16rpx 0rpx 0rpx;
		transform: translateY(-3rpx);
	}
</style>